module Mi
  class Utils
    class Sql
      def self.exec sql
        conn = ActiveRecord::Base.connection();
        conn.execute "SET autocommit=0";
        conn.begin_db_transaction
        conn.execute(sql)
        conn.commit_db_transaction
      end
      def self.select sql
        retval = []
        conn = ActiveRecord::Base.connection()
        list = conn.execute(sql)
        list.each_hash{ |item| retval.push item }
        return retval
      end
    end
  end
end
